package com.finalproject.ui;
/**
 * CafeItemPanel for UI
 */
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.ScrollPane;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneLayout;

import com.finalproject.entity.CafeItem;
import com.finalproject.entity.SnackItem;

public class UICafeItemPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private JPanel jpanel;

	JScrollPane scrollPane;

	/**
	 * Create the panel.
	 */
	public UICafeItemPanel() {
		jpanel = new JPanel();
		setLayout(new BorderLayout());
		scrollPane = new JScrollPane(jpanel);
		jpanel.setPreferredSize(new Dimension(580, 2500));
		scrollPane.setPreferredSize(new Dimension(600, 500));
		scrollPane.setVisible(true);
		scrollPane.setLayout(new ScrollPaneLayout());

		add(scrollPane, BorderLayout.CENTER);

		setPreferredSize(new Dimension(600, 500));

	}

	public void add(UICafeItem uiCafeItem) {
		jpanel.add(uiCafeItem);
		jpanel.revalidate();
		scrollPane.revalidate();

	}
	
	public void removeAll() {
		jpanel.removeAll();
		revalidate();
		repaint();
	}

	public static void main(String[] args) {
		JFrame f = new JFrame("FormLayout: Default Form Builder Example 1");

		f.setDefaultCloseOperation(2);
		f.getContentPane().add(new UICafeItemPanel());
		f.pack();
		f.setSize(500, 600);

		f.setVisible(true);
	}
}
